package com.cskaoyan.service.wx.impl;

import com.cskaoyan.bean.pojo.Feedback;
import com.cskaoyan.bean.pojo.User;
import com.cskaoyan.bean.wx.feedback.bo.WxFeedbackBo;
import com.cskaoyan.bean.wx.feedback.vo.WxFeedbackVo;
import com.cskaoyan.mapper.FeedbackMapper;
import com.cskaoyan.service.wx.WxFeedbackService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Timestamp;
import java.util.Date;

/**
 * @program: project-two
 * @description:
 * @author: YuHui
 * @create: 2021-08-15 12:14
 **/
@Transactional
@Service
public class WxFeedbackServiceImpl implements WxFeedbackService {

    @Autowired
    FeedbackMapper feedbackMapper;

    @Override
    public void submit(WxFeedbackBo wxFeedbackBo) {

        String[] picUrls = wxFeedbackBo.getPicUrls();

        Feedback feedback = new Feedback();

        for (String picUrl : picUrls) {
            feedback.setMobile(wxFeedbackBo.getMobile());
            feedback.setFeedType(wxFeedbackBo.getFeedType());
            feedback.setContent(wxFeedbackBo.getContent());
            feedback.setHasPicture(wxFeedbackBo.getHasPicture());
            feedback.setPicUrls(picUrl);
            feedback.setStatus(0);
        }

        User user = new User();
        user.setId(1098251163);
        user.setNickname("小摆摆");
        Integer id = user.getId();
        feedback.setUserId(id);
        String nickname = user.getNickname();
        feedback.setUsername(nickname);

        Date date = new Date();
        long time = date.getTime();
        Timestamp timestamp = new Timestamp(time);

        feedback.setAddTime(timestamp);
        feedback.setUpdateTime(timestamp);
        feedbackMapper.insert(feedback);

    }
}
